package com.wooboo.server.ext.data;

/**
* <p>Title: 哇棒移动广告平台</p>
*
* <p>Description: Wooboo Advertising Platform</p>
*
* <p>Copyright: Copyright (c) 2015.5.28</p>
*
* <p>Company: Wooboo</p>
*
* 类名称：RestModel    
* 类描述：    REST 返回JSON 标准对象
* 创建人：duanwei    
* 创建时间：2015-5-28 下午5:13:21    
* 修改人：duanwei    
* 修改时间：2015-5-28 下午5:13:21    
* 修改备注：    
* 
* @author duanwei
* 
* @version 1.0.0
*/

public class RestModel  {
	
	
	public RestModel(){
		
	}
	
	/**
	 * 响应码
	 */
	private long code;
	/**
	 * 响应描述
	 */
	private String errorDescription = "";
	/**
	 * 响应数据
	 */
	private Object dataObject="" ;
	
	public long getCode() {
		return code;
	}
	public void setCode(long code) {
		this.code = code;
	}

	public String getErrorDescription() {
		return errorDescription;
	}

	public void setErrorDescription(String errorDescription) {
		this.errorDescription = errorDescription;
	}
	
	public static RestModel getRestModel(long code,String desc){
		RestModel m=new RestModel();
		m.setCode(code);
		m.setErrorDescription(desc);
		return m;
	}
	
	public static RestModel getResModel(long code,String desc,Object data){
		RestModel rm=new RestModel();
		rm.setCode(code);
		rm.setErrorDescription(desc);
		rm.setDataObject(data);
		return rm;
	}
	
	public static String strToJson(String key,String val){
		
		return "{\""+key+"\":\""+val+"\"}";
	}
	public Object getDataObject() {
		return dataObject;
	}

	public void setDataObject(Object dataObject) {
		this.dataObject = dataObject;
	}
	
	public String toString(){
		return "{\"code\":"+this.code+",\"errorDescription\":\""+this.errorDescription+"\",\"dataObject\":\""+this.dataObject+"\"}";
	}
	
}
